<template>
  <div class="page-subject-rent">
    <div class="subject-main">

      <!-- 专题页左边     -->
      <div class="main" style="position: relative">
        <img style="z-index:2; width: 100%; border-radius: 5px" src="https://carphoto.atzuche.com/pcWebService/imageFile/1695181075145.jpg" alt=""/>
        <div style="height: 150px;width: 718px; position: absolute; background: linear-gradient(hsla(0,0%,100%,0),#fff);z-index: 5; top:390px"></div>
        <div>
          <h1 style="font-size: 20px;">旅行租车</h1>
          <p style="font-size: 14px;color: #666">租车去旅行，让我们帮您预定一辆车，带您去追寻未知的风景，让您的旅行之路更加精彩！在这个假期，让我们一起租车去旅行，享受路上的每一刻！</p>
        </div>

        <div style="width: 100%; border: 1px solid rgb(237, 237, 237)"></div>
        <div style="padding: 20px">
          <el-row :gutter="20">
            <el-col :span="8" v-for="item in 12">
              <div class="recommend-car-item" style="text-align: left; position: relative;">
                <img src="https://carphoto.atzuche.com/car/18/08/430139100/1533787646061_1.jpg?x-oss-process=image/resize,m_lfit,h_315,w_480" style="width: 100%; --el-card-padding: 0px; border-radius: 5px;">
                <p style="font-size: 14px; opacity: 0.8; margin-bottom: 0;">本田 飞度 1.5L</p>
                <p style="margin: 0;">
                  <span style="font-size: 12px; opacity: 0.6;">沪A***J5</span> <span style="font-size: 12px; color: #ff5c5c"> 5.0分</span>
                </p>
                <p style="margin-top: 0;color: #ff5c5c; font-size: 12px;"><strong style="font-size: 16px;">2340</strong>元/月</p>
              </div>
            </el-col>
          </el-row>

        </div>

      </div>
      <!-- 专题页右边     -->
      <div class="aside">
        <div class="com-news-panel" style="width: 400px">
          <header>
            <h2 style="font-size: 20px;font-weight: 700">
              热点文章
              <img style="width: 30px" src="">
            </h2>
          </header>
          <div class="list">
            <router-link :to="'/newsDetail/' + item.id"  class="news-item article-item" v-for="item in HotNews" style="text-decoration: none">
              {{item.title}}
            </router-link>
          </div>
        </div>
        <div class="com-news-panel">
          <h2 style="font-size: 20px;font-weight: 700">
            相关专题
          </h2>
          <el-row :gutter="20">
            <el-col :span="12" >

              <div style="width: 100%; height:150px; margin-bottom: 20px; position: relative">
                <a v-for="item in topicList" href="#" style=" text-decoration: none; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif">
                  <img :src="item.pic" style="width: 100%; height: 100%; border-radius: 5px;">
                  <h3 style="position: relative; top: -40px; z-index: 10; margin: 0; font-size: 16px; color: #fff; left: 25px;">{{ item.topicTitle }}</h3>
                </a>
              </div>


            </el-col>
          </el-row>
        </div>
      </div>
    </div>

  </div>


</template>

<style scoped>
.page-subject-rent {
  width: 1100px;
  padding-bottom: 40px;
  margin: 0 auto 20px;

}

.at-breadcrumb>a {
  display: block;
  color: #999;
}


.at-breadcrumb>span {
  display: block;
  padding: 0 5px;
}

.page-subject-rent .subject-main {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: start;
  align-items: flex-start;
  margin-bottom: 40px;
}


.page-subject-rent .subject-main .main {
  -ms-flex: 1 1;
  flex: 1 1;
  width: 100%;
  margin-right: 20px;
  border: 1px solid #f5f5f5;

  border-radius: 5px;
}

.main {
  width: 1024px;
}


.page-subject-rent .subject-main .main>h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.page-subject-rent .subject-main .main .list {
  overflow: hidden;
  margin-right: -20px;
}


.page-subject-rent .subject-main .main .subject-item {
  width: 290px;
  float: left;
  margin: 0 20px 20px 0;
  display: block;
  -webkit-transition: all .2s ease-out;
  transition: all .2s ease-out;
  border-radius: 5px;
}


.page-subject-rent .subject-main .main .subject-item .header {
  display: block;
  position: relative;
  width: 100%;
  height: 150px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  overflow: hidden;
}

.page-subject-rent .subject-main .main .subject-item .header img {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #f0f0f0;
}

.page-subject-rent .subject-main .main .subject-item .header h3 {
  position: absolute;
  left: 15px;
  bottom: 15px;
  font-size: 17px;
  color: #fff;
  font-weight: 700;
}


.page-subject-rent .subject-main .main .subject-item .text {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  border: 1px solid #f5f5f5;
  border-top: none;
  padding: 15px;
}
.page-subject-rent .subject-main .main .subject-item .text p {
  font-size: 14px;
  line-height: 20px;
  height: 60px;
  overflow: hidden;
}

.page-subject-rent .subject-main .main .pagination {
  margin-top: 20px;
}



.page-subject-rent .subject-main .aside {
  width: 360px;
}

.com-news-panel {
  border: 1px solid #f5f5f5;
  padding: 20px;
  border-radius: 5px;
}

.com-news-panel header {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
}
.com-news-panel header h2 {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
}

.com-news-panel header>* {
  font-weight: 700;
}

.com-news-panel .list {
  display: block;
  overflow: hidden;
}
.com-news-panel a.news-item {
  display: -ms-flexbox;
  display: flex;
  color: #666;
  font-size: 12px;
  margin-bottom: 15px;
  background: url() 0 no-repeat;
  background-size: 4px auto;
  padding-left: 10px;
}
a.news-item:hover{
  color: #00bc93;
}
.com-news-panel a.news-item:last-child {
  margin-bottom: 0;
}
.com-news-panel a.news-item .p {
  overflow: hidden;
  white-space: nowrap;
  max-width: 80%;
}
.com-news-panel a.news-item .dot {
  display: block;
  width: 100%;
  -ms-flex: 1 1;
  flex: 1 1;
  background: url() 0 repeat-x;
  background-size: 4px auto;
  margin: 0 10px;
}

.page-subject-rent .hot-cars-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}


</style>

<script setup>
import {onMounted, ref} from "vue";
import request from '@/utils/request';
import {ElMessage} from "element-plus";
import {useRoute} from "vue-router";
let id
onMounted(()=>{
  id= useRoute().params.id;
  console.log(id)
})

//热点文章
const HotNews = ref([]);
//热点文章-----------------------------------------
const getHotNews = () => {
  let url = `/v1/news/hot`;
  request.get(url).then((response) => {
    if (response.code === 200) {
      console.log(response.data);
      HotNews.value = response.data;
    } else {
      ElMessage.error(response.data.msg);
    }
  })
};

// 租车专题 --------------------------------------------------
const topicList = ref([]);

const getTopicList = () => {
  let url = `/topics`;
  request.get(url).then((response) => {
    if (response.code === 200) {
      // console.log(response.data);
      topicList.value = response.data.list.slice(0, 4);
    } else {
      ElMessage.error(response.data.msg);
    }
  })
};


onMounted(() => {
  getTopicList();
  getHotNews();
})

</script>